package ru.spbau.database.group3.index;

import java.io.Serializable;

import ru.spbau.database.group3.filesAndAccess.Record;

public class IndexBTreeData implements Comparable<IndexBTreeData>, Serializable{

	private Record record;
	private IndexKeyType type;
	
	public IndexBTreeData(Record record, IndexKeyType type) {
		this.record = record;
		this.type = type;
	}
	
	@Override
	public int compareTo(IndexBTreeData o) {
		return type.compare(record, o.record);
	}
	
	@Override
	public boolean equals(Object o) {
		if (o instanceof IndexBTreeData) {
			IndexBTreeData treeO = (IndexBTreeData) o;
			return type.compare(record, treeO.record) == 0;
		} else {
			return false;
		}
	}
	
	public Record getRecord() {
		return record;
	}

	@Override
	public String toString() {
		return record.toString();
	}
}
